import { createRouter, createWebHashHistory } from "vue-router"

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: "/",
      redirect: "/home"
    },
    {
      path: "/login",
      component: () => import("@/views/login/login.vue")
    },
    {
      path: "/home",
      component: () => import("@/views/main/home.vue"),
    },
    {
      path: "/show/:name",
      component: () => import("@/views/main/show.vue"),
    }
  ]
})

// 导航守卫: 拦截没有登录时返回登录页面
// router.beforeEach((to) => {
//   const token = localStorage.getItem("token")
//   // 进入到main页面, 没有token返回登录页面
//   if (to.path !== "/login" && !token) return "/login"
// })
export default router